//
//  ZYLiveT1462958418713.m
//
//  Created by Yeewii@hotmail com on 16/6/29
//  Copyright (c) 2016 __MyCompanyName__. All rights reserved.
//

#import "ZYLiveT1462958418713.h"
#import "ZYLiveLiveInfo.h"
#import "ZYLiveSpecialextra.h"


NSString *const kZYLiveT1462958418713Tname = @"tname";
NSString *const kZYLiveT1462958418713Ptime = @"ptime";
NSString *const kZYLiveT1462958418713Source = @"source";
NSString *const kZYLiveT1462958418713Title = @"title";
NSString *const kZYLiveT1462958418713ImgType = @"imgType";
NSString *const kZYLiveT1462958418713TAG = @"TAG";
NSString *const kZYLiveT1462958418713Specialtip = @"specialtip";
NSString *const kZYLiveT1462958418713LiveInfo = @"live_info";
NSString *const kZYLiveT1462958418713HasHead = @"hasHead";
NSString *const kZYLiveT1462958418713HasImg = @"hasImg";
NSString *const kZYLiveT1462958418713Lmodify = @"lmodify";
NSString *const kZYLiveT1462958418713Template = @"template";
NSString *const kZYLiveT1462958418713Imgsrc = @"imgsrc";
NSString *const kZYLiveT1462958418713Docid = @"docid";
NSString *const kZYLiveT1462958418713Alias = @"alias";
NSString *const kZYLiveT1462958418713TAGS = @"TAGS";
NSString *const kZYLiveT1462958418713HasCover = @"hasCover";
NSString *const kZYLiveT1462958418713HasAD = @"hasAD";
NSString *const kZYLiveT1462958418713Priority = @"priority";
NSString *const kZYLiveT1462958418713Cid = @"cid";
NSString *const kZYLiveT1462958418713SkipType = @"skipType";
NSString *const kZYLiveT1462958418713Specialadlogo = @"specialadlogo";
NSString *const kZYLiveT1462958418713HasIcon = @"hasIcon";
NSString *const kZYLiveT1462958418713Subtitle = @"subtitle";
NSString *const kZYLiveT1462958418713Speciallogo = @"speciallogo";
NSString *const kZYLiveT1462958418713Ename = @"ename";
NSString *const kZYLiveT1462958418713SpecialID = @"specialID";
NSString *const kZYLiveT1462958418713Editor = @"editor";
NSString *const kZYLiveT1462958418713Specialextra = @"specialextra";
NSString *const kZYLiveT1462958418713SkipID = @"skipID";
NSString *const kZYLiveT1462958418713Order = @"order";
NSString *const kZYLiveT1462958418713Digest = @"digest";


@interface ZYLiveT1462958418713 ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation ZYLiveT1462958418713

@synthesize tname = _tname;
@synthesize ptime = _ptime;
@synthesize source = _source;
@synthesize title = _title;
@synthesize imgType = _imgType;
@synthesize tAG = _tAG;
@synthesize specialtip = _specialtip;
@synthesize liveInfo = _liveInfo;
@synthesize hasHead = _hasHead;
@synthesize hasImg = _hasImg;
@synthesize lmodify = _lmodify;
@synthesize template = _template;
@synthesize imgsrc = _imgsrc;
@synthesize docid = _docid;
@synthesize alias = _alias;
@synthesize tAGS = _tAGS;
@synthesize hasCover = _hasCover;
@synthesize hasAD = _hasAD;
@synthesize priority = _priority;
@synthesize cid = _cid;
@synthesize skipType = _skipType;
@synthesize specialadlogo = _specialadlogo;
@synthesize hasIcon = _hasIcon;
@synthesize subtitle = _subtitle;
@synthesize speciallogo = _speciallogo;
@synthesize ename = _ename;
@synthesize specialID = _specialID;
@synthesize editor = _editor;
@synthesize specialextra = _specialextra;
@synthesize skipID = _skipID;
@synthesize order = _order;
@synthesize digest = _digest;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.tname = [self objectOrNilForKey:kZYLiveT1462958418713Tname fromDictionary:dict];
            self.ptime = [self objectOrNilForKey:kZYLiveT1462958418713Ptime fromDictionary:dict];
            self.source = [self objectOrNilForKey:kZYLiveT1462958418713Source fromDictionary:dict];
            self.title = [self objectOrNilForKey:kZYLiveT1462958418713Title fromDictionary:dict];
            self.imgType = [[self objectOrNilForKey:kZYLiveT1462958418713ImgType fromDictionary:dict] doubleValue];
            self.tAG = [self objectOrNilForKey:kZYLiveT1462958418713TAG fromDictionary:dict];
            self.specialtip = [self objectOrNilForKey:kZYLiveT1462958418713Specialtip fromDictionary:dict];
            self.liveInfo = [ZYLiveLiveInfo modelObjectWithDictionary:[dict objectForKey:kZYLiveT1462958418713LiveInfo]];
            self.hasHead = [[self objectOrNilForKey:kZYLiveT1462958418713HasHead fromDictionary:dict] doubleValue];
            self.hasImg = [[self objectOrNilForKey:kZYLiveT1462958418713HasImg fromDictionary:dict] doubleValue];
            self.lmodify = [self objectOrNilForKey:kZYLiveT1462958418713Lmodify fromDictionary:dict];
            self.template = [self objectOrNilForKey:kZYLiveT1462958418713Template fromDictionary:dict];
            self.imgsrc = [self objectOrNilForKey:kZYLiveT1462958418713Imgsrc fromDictionary:dict];
            self.docid = [self objectOrNilForKey:kZYLiveT1462958418713Docid fromDictionary:dict];
            self.alias = [self objectOrNilForKey:kZYLiveT1462958418713Alias fromDictionary:dict];
            self.tAGS = [self objectOrNilForKey:kZYLiveT1462958418713TAGS fromDictionary:dict];
            self.hasCover = [[self objectOrNilForKey:kZYLiveT1462958418713HasCover fromDictionary:dict] boolValue];
            self.hasAD = [[self objectOrNilForKey:kZYLiveT1462958418713HasAD fromDictionary:dict] doubleValue];
            self.priority = [[self objectOrNilForKey:kZYLiveT1462958418713Priority fromDictionary:dict] doubleValue];
            self.cid = [self objectOrNilForKey:kZYLiveT1462958418713Cid fromDictionary:dict];
            self.skipType = [self objectOrNilForKey:kZYLiveT1462958418713SkipType fromDictionary:dict];
            self.specialadlogo = [self objectOrNilForKey:kZYLiveT1462958418713Specialadlogo fromDictionary:dict];
            self.hasIcon = [[self objectOrNilForKey:kZYLiveT1462958418713HasIcon fromDictionary:dict] boolValue];
            self.subtitle = [self objectOrNilForKey:kZYLiveT1462958418713Subtitle fromDictionary:dict];
            self.speciallogo = [self objectOrNilForKey:kZYLiveT1462958418713Speciallogo fromDictionary:dict];
            self.ename = [self objectOrNilForKey:kZYLiveT1462958418713Ename fromDictionary:dict];
            self.specialID = [self objectOrNilForKey:kZYLiveT1462958418713SpecialID fromDictionary:dict];
            self.editor = [self objectOrNilForKey:kZYLiveT1462958418713Editor fromDictionary:dict];
    NSObject *receivedZYLiveSpecialextra = [dict objectForKey:kZYLiveT1462958418713Specialextra];
    NSMutableArray *parsedZYLiveSpecialextra = [NSMutableArray array];
    if ([receivedZYLiveSpecialextra isKindOfClass:[NSArray class]]) {
        for (NSDictionary *item in (NSArray *)receivedZYLiveSpecialextra) {
            if ([item isKindOfClass:[NSDictionary class]]) {
                [parsedZYLiveSpecialextra addObject:[ZYLiveSpecialextra modelObjectWithDictionary:item]];
            }
       }
    } else if ([receivedZYLiveSpecialextra isKindOfClass:[NSDictionary class]]) {
       [parsedZYLiveSpecialextra addObject:[ZYLiveSpecialextra modelObjectWithDictionary:(NSDictionary *)receivedZYLiveSpecialextra]];
    }

    self.specialextra = [NSArray arrayWithArray:parsedZYLiveSpecialextra];
            self.skipID = [self objectOrNilForKey:kZYLiveT1462958418713SkipID fromDictionary:dict];
            self.order = [[self objectOrNilForKey:kZYLiveT1462958418713Order fromDictionary:dict] doubleValue];
            self.digest = [self objectOrNilForKey:kZYLiveT1462958418713Digest fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.tname forKey:kZYLiveT1462958418713Tname];
    [mutableDict setValue:self.ptime forKey:kZYLiveT1462958418713Ptime];
    [mutableDict setValue:self.source forKey:kZYLiveT1462958418713Source];
    [mutableDict setValue:self.title forKey:kZYLiveT1462958418713Title];
    [mutableDict setValue:[NSNumber numberWithDouble:self.imgType] forKey:kZYLiveT1462958418713ImgType];
    [mutableDict setValue:self.tAG forKey:kZYLiveT1462958418713TAG];
    [mutableDict setValue:self.specialtip forKey:kZYLiveT1462958418713Specialtip];
    [mutableDict setValue:[self.liveInfo dictionaryRepresentation] forKey:kZYLiveT1462958418713LiveInfo];
    [mutableDict setValue:[NSNumber numberWithDouble:self.hasHead] forKey:kZYLiveT1462958418713HasHead];
    [mutableDict setValue:[NSNumber numberWithDouble:self.hasImg] forKey:kZYLiveT1462958418713HasImg];
    [mutableDict setValue:self.lmodify forKey:kZYLiveT1462958418713Lmodify];
    [mutableDict setValue:self.template forKey:kZYLiveT1462958418713Template];
    [mutableDict setValue:self.imgsrc forKey:kZYLiveT1462958418713Imgsrc];
    [mutableDict setValue:self.docid forKey:kZYLiveT1462958418713Docid];
    [mutableDict setValue:self.alias forKey:kZYLiveT1462958418713Alias];
    [mutableDict setValue:self.tAGS forKey:kZYLiveT1462958418713TAGS];
    [mutableDict setValue:[NSNumber numberWithBool:self.hasCover] forKey:kZYLiveT1462958418713HasCover];
    [mutableDict setValue:[NSNumber numberWithDouble:self.hasAD] forKey:kZYLiveT1462958418713HasAD];
    [mutableDict setValue:[NSNumber numberWithDouble:self.priority] forKey:kZYLiveT1462958418713Priority];
    [mutableDict setValue:self.cid forKey:kZYLiveT1462958418713Cid];
    [mutableDict setValue:self.skipType forKey:kZYLiveT1462958418713SkipType];
    [mutableDict setValue:self.specialadlogo forKey:kZYLiveT1462958418713Specialadlogo];
    [mutableDict setValue:[NSNumber numberWithBool:self.hasIcon] forKey:kZYLiveT1462958418713HasIcon];
    [mutableDict setValue:self.subtitle forKey:kZYLiveT1462958418713Subtitle];
    [mutableDict setValue:self.speciallogo forKey:kZYLiveT1462958418713Speciallogo];
    [mutableDict setValue:self.ename forKey:kZYLiveT1462958418713Ename];
    [mutableDict setValue:self.specialID forKey:kZYLiveT1462958418713SpecialID];
    NSMutableArray *tempArrayForEditor = [NSMutableArray array];
    for (NSObject *subArrayObject in self.editor) {
        if([subArrayObject respondsToSelector:@selector(dictionaryRepresentation)]) {
            // This class is a model object
            [tempArrayForEditor addObject:[subArrayObject performSelector:@selector(dictionaryRepresentation)]];
        } else {
            // Generic object
            [tempArrayForEditor addObject:subArrayObject];
        }
    }
    [mutableDict setValue:[NSArray arrayWithArray:tempArrayForEditor] forKey:kZYLiveT1462958418713Editor];
    NSMutableArray *tempArrayForSpecialextra = [NSMutableArray array];
    for (NSObject *subArrayObject in self.specialextra) {
        if([subArrayObject respondsToSelector:@selector(dictionaryRepresentation)]) {
            // This class is a model object
            [tempArrayForSpecialextra addObject:[subArrayObject performSelector:@selector(dictionaryRepresentation)]];
        } else {
            // Generic object
            [tempArrayForSpecialextra addObject:subArrayObject];
        }
    }
    [mutableDict setValue:[NSArray arrayWithArray:tempArrayForSpecialextra] forKey:kZYLiveT1462958418713Specialextra];
    [mutableDict setValue:self.skipID forKey:kZYLiveT1462958418713SkipID];
    [mutableDict setValue:[NSNumber numberWithDouble:self.order] forKey:kZYLiveT1462958418713Order];
    [mutableDict setValue:self.digest forKey:kZYLiveT1462958418713Digest];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.tname = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Tname];
    self.ptime = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Ptime];
    self.source = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Source];
    self.title = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Title];
    self.imgType = [aDecoder decodeDoubleForKey:kZYLiveT1462958418713ImgType];
    self.tAG = [aDecoder decodeObjectForKey:kZYLiveT1462958418713TAG];
    self.specialtip = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Specialtip];
    self.liveInfo = [aDecoder decodeObjectForKey:kZYLiveT1462958418713LiveInfo];
    self.hasHead = [aDecoder decodeDoubleForKey:kZYLiveT1462958418713HasHead];
    self.hasImg = [aDecoder decodeDoubleForKey:kZYLiveT1462958418713HasImg];
    self.lmodify = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Lmodify];
    self.template = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Template];
    self.imgsrc = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Imgsrc];
    self.docid = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Docid];
    self.alias = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Alias];
    self.tAGS = [aDecoder decodeObjectForKey:kZYLiveT1462958418713TAGS];
    self.hasCover = [aDecoder decodeBoolForKey:kZYLiveT1462958418713HasCover];
    self.hasAD = [aDecoder decodeDoubleForKey:kZYLiveT1462958418713HasAD];
    self.priority = [aDecoder decodeDoubleForKey:kZYLiveT1462958418713Priority];
    self.cid = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Cid];
    self.skipType = [aDecoder decodeObjectForKey:kZYLiveT1462958418713SkipType];
    self.specialadlogo = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Specialadlogo];
    self.hasIcon = [aDecoder decodeBoolForKey:kZYLiveT1462958418713HasIcon];
    self.subtitle = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Subtitle];
    self.speciallogo = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Speciallogo];
    self.ename = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Ename];
    self.specialID = [aDecoder decodeObjectForKey:kZYLiveT1462958418713SpecialID];
    self.editor = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Editor];
    self.specialextra = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Specialextra];
    self.skipID = [aDecoder decodeObjectForKey:kZYLiveT1462958418713SkipID];
    self.order = [aDecoder decodeDoubleForKey:kZYLiveT1462958418713Order];
    self.digest = [aDecoder decodeObjectForKey:kZYLiveT1462958418713Digest];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_tname forKey:kZYLiveT1462958418713Tname];
    [aCoder encodeObject:_ptime forKey:kZYLiveT1462958418713Ptime];
    [aCoder encodeObject:_source forKey:kZYLiveT1462958418713Source];
    [aCoder encodeObject:_title forKey:kZYLiveT1462958418713Title];
    [aCoder encodeDouble:_imgType forKey:kZYLiveT1462958418713ImgType];
    [aCoder encodeObject:_tAG forKey:kZYLiveT1462958418713TAG];
    [aCoder encodeObject:_specialtip forKey:kZYLiveT1462958418713Specialtip];
    [aCoder encodeObject:_liveInfo forKey:kZYLiveT1462958418713LiveInfo];
    [aCoder encodeDouble:_hasHead forKey:kZYLiveT1462958418713HasHead];
    [aCoder encodeDouble:_hasImg forKey:kZYLiveT1462958418713HasImg];
    [aCoder encodeObject:_lmodify forKey:kZYLiveT1462958418713Lmodify];
    [aCoder encodeObject:_template forKey:kZYLiveT1462958418713Template];
    [aCoder encodeObject:_imgsrc forKey:kZYLiveT1462958418713Imgsrc];
    [aCoder encodeObject:_docid forKey:kZYLiveT1462958418713Docid];
    [aCoder encodeObject:_alias forKey:kZYLiveT1462958418713Alias];
    [aCoder encodeObject:_tAGS forKey:kZYLiveT1462958418713TAGS];
    [aCoder encodeBool:_hasCover forKey:kZYLiveT1462958418713HasCover];
    [aCoder encodeDouble:_hasAD forKey:kZYLiveT1462958418713HasAD];
    [aCoder encodeDouble:_priority forKey:kZYLiveT1462958418713Priority];
    [aCoder encodeObject:_cid forKey:kZYLiveT1462958418713Cid];
    [aCoder encodeObject:_skipType forKey:kZYLiveT1462958418713SkipType];
    [aCoder encodeObject:_specialadlogo forKey:kZYLiveT1462958418713Specialadlogo];
    [aCoder encodeBool:_hasIcon forKey:kZYLiveT1462958418713HasIcon];
    [aCoder encodeObject:_subtitle forKey:kZYLiveT1462958418713Subtitle];
    [aCoder encodeObject:_speciallogo forKey:kZYLiveT1462958418713Speciallogo];
    [aCoder encodeObject:_ename forKey:kZYLiveT1462958418713Ename];
    [aCoder encodeObject:_specialID forKey:kZYLiveT1462958418713SpecialID];
    [aCoder encodeObject:_editor forKey:kZYLiveT1462958418713Editor];
    [aCoder encodeObject:_specialextra forKey:kZYLiveT1462958418713Specialextra];
    [aCoder encodeObject:_skipID forKey:kZYLiveT1462958418713SkipID];
    [aCoder encodeDouble:_order forKey:kZYLiveT1462958418713Order];
    [aCoder encodeObject:_digest forKey:kZYLiveT1462958418713Digest];
}

- (id)copyWithZone:(NSZone *)zone
{
    ZYLiveT1462958418713 *copy = [[ZYLiveT1462958418713 alloc] init];
    
    if (copy) {

        copy.tname = [self.tname copyWithZone:zone];
        copy.ptime = [self.ptime copyWithZone:zone];
        copy.source = [self.source copyWithZone:zone];
        copy.title = [self.title copyWithZone:zone];
        copy.imgType = self.imgType;
        copy.tAG = [self.tAG copyWithZone:zone];
        copy.specialtip = [self.specialtip copyWithZone:zone];
        copy.liveInfo = [self.liveInfo copyWithZone:zone];
        copy.hasHead = self.hasHead;
        copy.hasImg = self.hasImg;
        copy.lmodify = [self.lmodify copyWithZone:zone];
        copy.template = [self.template copyWithZone:zone];
        copy.imgsrc = [self.imgsrc copyWithZone:zone];
        copy.docid = [self.docid copyWithZone:zone];
        copy.alias = [self.alias copyWithZone:zone];
        copy.tAGS = [self.tAGS copyWithZone:zone];
        copy.hasCover = self.hasCover;
        copy.hasAD = self.hasAD;
        copy.priority = self.priority;
        copy.cid = [self.cid copyWithZone:zone];
        copy.skipType = [self.skipType copyWithZone:zone];
        copy.specialadlogo = [self.specialadlogo copyWithZone:zone];
        copy.hasIcon = self.hasIcon;
        copy.subtitle = [self.subtitle copyWithZone:zone];
        copy.speciallogo = [self.speciallogo copyWithZone:zone];
        copy.ename = [self.ename copyWithZone:zone];
        copy.specialID = [self.specialID copyWithZone:zone];
        copy.editor = [self.editor copyWithZone:zone];
        copy.specialextra = [self.specialextra copyWithZone:zone];
        copy.skipID = [self.skipID copyWithZone:zone];
        copy.order = self.order;
        copy.digest = [self.digest copyWithZone:zone];
    }
    
    return copy;
}


@end
